#ifndef PHONEPWDLOGINWIDGET_H
#define PHONEPWDLOGINWIDGET_H

#include <QCheckBox>
#include <QLineEdit>
#include <QPushButton>
#include <QSslSocket>
#include <QToolButton>
#include <QVBoxLayout>
#include <QWidget>
#include "Functionality/functionalityFactory.h"
#include "hovertoolbutton.h"
#include "videoConferenceClient/videoconferencingclient.h"
#include <socketFacotry/socketFactoryInterface.h>

class phonePwdLoginWidget : public QWidget
{
    Q_OBJECT
public:
    explicit phonePwdLoginWidget(QWidget *parent = nullptr);

signals:

protected slots:
    void onLoginBtnClicked();
    void onRegisterClicked();
    void onLoginSuccessed(QString data);
    void onLoginFailed(QString data);

private:
    void addPhoneNumberLayout();
    void addPasswdLayout();
    void addSpaceLabel(int width, int height);
    bool eventFilter(QObject *watch, QEvent *event) override;
    void addLoginBtn();
    void addRemeberAndRegisteLayout();
    void bindConnect();
    bool isValidPhoneNumber(const QString &phoneNumber);
    void initSslSocket();

private:
    QVBoxLayout *mainVLayout;
    HoverToolButton *verificationCodeLogin;
    QLineEdit *phoneNumberlineEditor;
    QLineEdit *passwdLineEditor;
    QPushButton *forgetPasswdBtn;
    QPushButton *loginBtn;
    bool phoneNumberInput;
    bool passwdInput;
    QCheckBox *rememberPaawdBox;
    QPushButton *registrationBtn;

    //登录工厂
    std::shared_ptr<FunctionalityFactory> factory;
    std::shared_ptr<FunctionalityInterface> Functionality;
    //UDP客户端
    // videoConferencingClient videoClient; //这是登录的应该使用的是ssl
    //
    // socketFactoryInterface *sslSocketFactory;
    // QAbstractSocket *sslSocket; //这是使用工厂创建的ssl的服务器
};

#endif // PHONEPWDLOGINWIDGET_H
